<?php
/**
 * @filesource:					NodeAction.class.php
 * @desc:						操作节点模块管理
 * 
 * @author:						houyining
 * @copyright:					hou.yining@gmail.com	
 * @date:						2011-04-12
 */

class NodeAction extends CommonAction {
	public function index(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('node_manage'), 'sort' => C('CRUMB_LAST')),
		);
		
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array('uri' => '__URL__/add', 'title' => L('add_node'));
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		parent::index();
	}
	
	public function add(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('node_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/add', 'title' => L('add_node'), 'sort' => C('CRUMB_LAST')),
		);
		
		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array('uri' => '__URL__/index', 'title' => L('list_node'));
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$this->assign('group_list', $this->_getGroupList());
		parent::add();
	}
	
	public function edit(){
		$crumb_info = array(
			array('uri' => '__URL__', 'title' => L('node_manage'), 'sort' => C('CRUMB_DEFAULT')),
			array('uri' => '__URL__/edit/id/' . $_REQUEST['id'], 'title' => L('edit_node'), 'sort' => C('CRUMB_LAST')),
		);

		$this->_mergeCrumbInfo($crumb_info);
		$this->_action_link = array('uri' => '__URL__/index', 'title' => L('list_node'));
		
		$this->assign('crumb_info', $this->_crumb_info);
		$this->assign('action_link', $this->_action_link);
		$this->assign('group_list', $this->_getGroupList());
		parent::edit();
	}
	
	private function _getGroupList()
	{
		$Group = M('Group');
		$list  = $Group->where('status=1')->field('id, title')->select();
		return $list;
	}
}
?>